#ifndef GPIO_H_
#define GPIO_H_
/*******************************************************************************
 * File name: 		gpio.h
 * Description: 
 * Project: 		_lpc1788
 * Target: 			LPC1788
 * Compiler: 		arm-none-eabi-gcc
 * Date: 			05-07-2012
 * Author: 			Kuba
 * Based on: 		---
 ******************************************************************************/

/*==============================================================================
 Includes
==============================================================================*/
# include "typedef.h"
# include "irq.h"
/*==============================================================================
 Defines
==============================================================================*/

/*==============================================================================
 Types
==============================================================================*/
enum gpioPort {
	gpioPORT0,
	gpioPORT1,
	gpioPORT2,
	gpioPORT3,
	gpioPORT4,
	gpioPORT5
};

enum gpioDirection {
	gpioOUTPUT,
	gpioINPUT
};

enum gpioIrqConf{
	gpioRISING_EDGE,
	gpioFALLING_EDGE
};
/*==============================================================================
 Globals
==============================================================================*/

/*==============================================================================
 Global function prototypes
==============================================================================*/
/*------------------------------------------------------------------------------
 function name:		gpio32SetDir
 description:		set direction for 32 bit GPIO
 parameters:		port number, value, direction (output/input)
 returned value:	true or false
------------------------------------------------------------------------------*/
bool gpio32SetDir 	(const enum gpioPort port, const uint32 value, const enum gpioDirection dir);

/*------------------------------------------------------------------------------
 function name:		gpio32SetValue
 description:		set value for 32 bit GPIO port
 parameters:		port number, bit value
 returned value:	true or false
------------------------------------------------------------------------------*/
bool gpio32SetValue	(const enum gpioPort port, const uint32 value);

/*------------------------------------------------------------------------------
 function name:		gpio32ClearValue
 description:		clear value for 32 bit GPIO port
 parameters:		port number, bit value
 returned value:	true or false
------------------------------------------------------------------------------*/
bool gpio32ClearValue (const enum gpioPort port, const uint32 value);

/*------------------------------------------------------------------------------
 function name:		gpio32ToggleValue
 description:		toggle value for 32 bit GPIO port
 parameters:		port number, bit value
 returned value:	true or false
------------------------------------------------------------------------------*/
bool gpio32ToggleValue (const enum gpioPort port, const uint32 value);

/*------------------------------------------------------------------------------
 function name:		gpio32ReadValue
 description:		read value from 32 bit GPIO port
 parameters:		port number
 returned value:	current value of port
------------------------------------------------------------------------------*/
uint32 gpio32ReadValue (const enum gpioPort port);

/*------------------------------------------------------------------------------
 function name:		gpio32InitIrq
 description:		init GPIO port to generate interrupt. NOTE: only PORT0 and
 	 	 	 	 	 PORT2 can generate interrupt.
 parameters:		port number, pin, IRQ configuration, const pointer to user service
 returned value:	true or false
------------------------------------------------------------------------------*/
bool gpio32InitIrq	(const enum gpioPort port,
					const uint32 pin,
					const enum gpioIrqConf irqConf,
					const enum irqPriority priority,
					void (*const service)(void));

/******************************************************************************
* END OF FILE
******************************************************************************/
#endif /* GPIO_H_ */
